Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
Adding a document in an subcollection in an already existing document | Firebase v9

I'm trying to add a document to a subcollection in an existing document (check code below). When the document is being updated, there is being added a completely new document with the same id, but the existing document is not updated. How can I add the following data below in the already existing document, instead of making a new one?

Code:

const docRef = doc(db, "users", data.id);
const colRef = collection(docRef, 'teams')
addDoc(colRef, {
   id: response.data.account.id,
   role: 'owner',
   uid: data.id,
});

Firebase firestore

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As suggested by @dharmaraj, the issue could be caused by a trailing whitespace so a good way to check could be printing the data.id field using console.log('${data.id}').

This was confirmed by the OP and after the fix everything worked.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda